/**
 * 
 */
package org.hehui.supervisorysystem.ui.Preference.DatabasePPage;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 贺辉
 *
 */
public class DatabaseProperties {

	/**
	 * 
	 */
	
	List<DatabaseProperty> list = new ArrayList<DatabaseProperty>();
	
	public DatabaseProperties() {

	}

	


	private Object getDatabasePropertyList(){
		DatabaseProperty mySQLDBP = new DatabaseProperty("MySQL", 3306);
		list.add(mySQLDBP);
		
		DatabaseProperty derbyDBP = new DatabaseProperty("Apache Derby", 1527);
		list.add(derbyDBP);
		
		DatabaseProperty oracleDBP = new DatabaseProperty("Oracle", 1521);
		list.add(oracleDBP);
		
		DatabaseProperty msSQLServerDBP = new DatabaseProperty("M$ SQL Server", 1433);
		list.add(msSQLServerDBP);
		
		return list;	
	}
	
	public void dispose(){
		
	}
		
}




class DatabaseProperty{
	
		 String DBTypeName;
		 String DBName;
		 String DBServerHost;
		 int DBServerPort;
		 int defaultServerPort;
		 
		 
		public DatabaseProperty(String DBTypeName, int defaultServerPort) {

			this.DBTypeName = DBTypeName;
			this.defaultServerPort = defaultServerPort;
			
		}

		/**
		 * @return the dBTypeName
		 */
		public String getDBTypeName() {
			return DBTypeName;
		}
		
		/**
		 * @param typeName the dBTypeName to set
		 */
		public void setDBTypeName(String typeName) {
			DBTypeName = typeName;
		}
		
		/**
		 * @return the dBClassName
		 */
		public String getDBClassName() {
			String DBClassName = "";
			switch (defaultServerPort) {
			case 3306:
				DBClassName  = "com.mysql.jdbc.Driver";
				break;
			case 1527:
				DBClassName = "org.apache.derby.jdbc.ClientDriver";
				break;
			case 1521:
				DBClassName = "oracle.jdbc.driver.OracleDriver";
				break;
			case 1433:
				DBClassName = "net.sourceforge.jtds.jdbc.Driver";
				break;

			default:
				break;
			}
			return DBClassName;
		}
		

		/**
		 * @return the dBName
		 */
		public String getDBName() {
			return DBName;
		}
		
		/**
		 * @param name the dBName to set
		 */
		public void setDBName(String name) {
			DBName = name;
		}
		
		/**
		 * @return the dBServerHost
		 */
		public String getDBServerHost() {
			return DBServerHost;
		}

		/**
		 * @param serverHost the dBServerHost to set
		 */
		public void setDBServerHost(String serverHost) {
			DBServerHost = serverHost;
		}

		/**
		 * @return the dBServerPort
		 */
		public int getDBServerPort() {
			return DBServerPort;
		}
		
		/**
		 * @param serverPort the dBServerPort to set
		 */
		public void setDBServerPort(int serverPort) {
			DBServerPort = serverPort;
		}
		
		/**
		 * @return the dBURLString
		 */
		public String getDBURLString() {
			
			String DBURLString = "";
			
			switch (defaultServerPort) {
			case 3306:
				DBURLString = "jdbc:mysql//" + DBServerHost + ":" + DBServerPort + "/" + DBName;
				break;
			case 1527:
				DBURLString = "jdbc:derby://" + DBServerHost + ":" + DBServerPort + "/" + DBName;
				break;
			case 1521:
				DBURLString = "jdbc:oracle:thin:@" + DBServerHost + ":" + DBServerPort + ":" + DBName;
				break;
			case 1433:
				DBURLString = "jdbc:jtds:sqlserver://" + DBServerHost + ":" + DBServerPort + ";" + "DatabaseName=" + DBName;
				break;

			default:
				break;
			}
			return DBURLString;
		}
		

		public void dispose(){
			
			 DBTypeName = "";
			 DBName = "";
			 DBServerHost = "";
			
		}
		 
		 
	}